﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.WebApi
{
    /// <summary>
    /// 系统的错误代码
    /// </summary>
    static class ErrorCode
    {
        public const int NoError = 0xFF01;

        /// <summary>
        /// action not found
        /// </summary>
        public const int ActionNotFound = 0xFF02;

        /// <summary>
        /// 无效的参数
        /// </summary>
        public const int Common_InvalidParameter = 0xFF03;

        /// <summary>
        /// 认证
        /// 认证失败，没有认证信息
        /// Authentication
        /// </summary>
        public const int Auth_NoAuth = 0xFF04;

        /// <summary>
        /// 认证
        /// 认证失败，已超时
        /// </summary>
        public const int Auth_Timeout = 0xFF05;
        /// <summary>
        /// 错误的HttpMethod
        /// </summary>
        public const int InvalidHttpMethod = 0xFF06;

        public static string ToString(int code)
        {
            if (code == NoError)
            {
                return "No Error";
            }
            if (code == ActionNotFound)
            {
                return "Action Not Found";
            }
            if (code == InvalidHttpMethod)
            {
                return "Invalid HttpMethod";
            }
            if (code == Common_InvalidParameter)
            {
                return "无效的参数";
            }
            if (code == Auth_NoAuth)
            {
                return "认证失败，没有认证信息";
            }
            if (code == Auth_Timeout)
            {
                return "认证失败，已超时";
            }
            return "Unkonwn";
        }
    }
}
